//
//  GROrderManagerAction.m
//  YC_GRice
//
//  Created by luojinrong11 on 2018/7/21.
//  Copyright © 2018年 YeCai. All rights reserved.
//

#import "GROrderManagerAction.h"

@implementation GROrderManagerAction
-(void)requestOrderList:(NSDictionary *)dic CallBack:(void(^)(NSArray * listArr,NSInteger totalNum,BOOL success))callBck{
    [RequestManager getOderList:dic CompleteHander:^(BOOL success, id responseObject, GRError *error) {
        if (success) {
                NSMutableArray * goodArr =  [NSMutableArray array];
            if ( Array( responseObject[@"dataList"])) {
                for (NSDictionary * goodListDic in responseObject[@"dataList"]) {
                    GROrderListModel * listGoodModel = [GROrderListModel yy_modelWithDictionary:goodListDic];
                    [goodArr addObject:listGoodModel];
                }
            }
                callBck(goodArr,[responseObject[@"totalNumber"] integerValue],YES );
       
        }else{
            callBck(nil,0,NO);
        }
    }];
}
-(void)requestOrderDetail:(NSInteger)orderId CallBack:(void(^)(GROrderListModel * listModel,GRError *error))callBck{
    [RequestManager getOrderDetail:orderId CompleteHander:^(BOOL success, id responseObject, GRError *error) {
 
        if (success) {
            if (Dictionary(responseObject)) {
                NSLog(@"订单详情%@",responseObject);
                GROrderListModel  *listModel = [GROrderListModel yy_modelWithDictionary:responseObject];
                callBck(listModel,nil);
            }
        }else{
           callBck(nil,error);
        }

    }];
}
-(void)cancleOrder:(NSInteger)ordrId CallBack:(void(^)(BOOL success))callBck{
    [RequestManager cancleOrderWithOrderId:ordrId CompleteHander:^(BOOL success, id responseObject, GRError *error) {
        if (success) {
            callBck(success);
        }
    }];
}
-(void)confirmOrder:(NSInteger)orderId CallBack:(void(^)(BOOL success))callBck{
    [RequestManager confirmOrderWithOrderId:orderId CompleteHander:^(BOOL success, id responseObject, GRError *error) {
        if (success) {
            callBck(success);
        }
    }];
    
}
-(void)returnMoney:(NSInteger)ordrId ResonType:(NSInteger)resonType CallBack:(void (^)(BOOL))callBck{
    [RequestManager ReturnMoneyWithOrderId:ordrId ResonType:resonType CompleteHander:^(BOOL success, id responseObject, GRError *error) {
        if (success) {
            callBck(success);
        }else{
            [GRHUD showMessage:error.errorMsg];
        }
    }];
}
+(NSString *)getGradeDes:(NSInteger)score{
    switch (score) {
        case 1:
            return @"吐槽";
            break;
        case 2:
            return @"较差";
            break;
        case 3:
            return @"一般";
            break;
        case 4:
            return @"满意";
            break;
        case 5:
            return @"超赞";
            break;
            
        default:
            return @"";
            break;
    }
}

@end
